package com.yanjr.modules.ad.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.yanjr.common.persistence.Page;
import com.yanjr.common.utils.IdGen;
import com.yanjr.common.utils.StringUtils;
import com.yanjr.modules.ad.dao.AdLogDao;
import com.yanjr.modules.ad.entity.AdLog;
import com.yanjr.modules.ad.service.AdLogService;

@Service("adLogService")
@Transactional(readOnly = true)
public class AdLogServiceImpl implements AdLogService {

	@Autowired
	private AdLogDao adLogDao;
	
	@Override
	public AdLog get(String id) {
		return adLogDao.get(id);
	}

	@Override
	@Transactional(readOnly = false)
	public void save(AdLog adLog) {
		if(StringUtils.isEmpty(adLog.getId())) {
			adLog.setId(IdGen.uuid());
			adLogDao.save(adLog);
		} else {
			adLogDao	.update(adLog);
		}
	}

	@Override
	@Transactional(readOnly = false)
	public int delete(String id) {
		return adLogDao.delete(id);
	}

	@Override
	public Page<AdLog> find(Page<AdLog> page, AdLog adLog) {
		StringBuffer sql = new StringBuffer("select * from ad_log where 1=1 ");
		// TODO
		return adLogDao.findPage(page, sql.toString());
	}
	
	
}
